// 自定义校验
const validateKey1 = (rule, value, callback) => {
    const isChinese = /^[\u4e00-\u9fa5]+$/
    if (!isChinese.test(value)) {
        callback(new Error('姓名必须为中文'))
    } else {
        callback()
    }
}

export const modalFormConfig = {
    // 表单循环每一项样式
    itemStyle: {
        padding: '15px 0px'
    },
    // 表单栅格布局
    colLayout: { span: 12 },
    // 表单循环每一项配置
    formItems: [
        {
            field: 'name',
            type: 'input',
            label: '姓名',
            isHidden: false,
            rules: [
                {
                    required: true,
                    message: '姓名不能为空',
                    trigger: 'blur'
                },
                {
                    validator: validateKey1,
                    trigger: 'blur'
                }
            ],
            otherOptions: {
                disabled: false,
                placeholder: '请输入姓名',
            }
        },
        {
            field: 'age',
            type: 'inputNumber',
            label: '年龄',
            isHidden: false,
            rules: [
                {
                    required: true,
                    message: '年龄不能为空',
                    trigger: 'blur'
                }
            ],
            otherOptions: {
                min: 1,
                max: 30,
                placeholder: '请输入年龄',
            }
        },
        {
            field: 'gender',
            type: 'select',
            label: '性别',
            isHidden: false,
            rules: [
                {
                    required: true,
                    message: '性别不能为空',
                    trigger: 'blur'
                }
            ],
            options: [
                { value: 1, label: "男" },
                { value: 2, label: "女" }
            ],
            otherOptions: {
                placeholder: '请选择性别',
            }
        }
    ],
    // 表单配置项
    formAttrConfig: {
        // 文字宽度
        labelWidth: '90px',
        // 表单禁用
        disabled: false
    }
}

// 弹框属性配置
export const dialogConfig = {
    title: "",
    width: "60%",
    top: "10vh",
    center: true,
    destroyOnClose: true,
    showClose: true
}